package org.neu.onlineparadise.config;

import org.neu.onlineparadise.Interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;  //实例化并注入Bean

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册loginInterceptor登录拦截器到拦截器链，并指定路径/user/login和/user/register不会被拦截
        registry.addInterceptor(loginInterceptor).excludePathPatterns("/user/login","/user/register");
    }
}
